package com.hainatong.shiphelper.module.OAmgr;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.hainatong.shiphelper.Constants;
import com.hainatong.shiphelper.mainhome.ComFragmentActivity;
import com.hainatong.shiphelper.MvvmLazyFragment;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.databinding.FragmentListViewBinding;
import com.hainatong.shiphelper.mainhome.adapter.SubFunctionAdapter;
import com.hainatong.shiphelper.mainhome.entity.FunctionEntity;
import com.hainatong.mvvmbase.base.NoViewModel;

import java.util.ArrayList;
import java.util.List;

public class OAMgrFragment extends MvvmLazyFragment<FragmentListViewBinding, NoViewModel>
{
    private SubFunctionAdapter adapter;

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_list_view;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {

    }

    @Override
    protected void initView(View view)
    {
        adapter = new SubFunctionAdapter();
        viewDataBinding.recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        viewDataBinding.recyclerview.setHasFixedSize(true);
        viewDataBinding.recyclerview.setAdapter(adapter);
        List<FunctionEntity> funList = new ArrayList<>();
        funList.add(new FunctionEntity(getString(R.string.waite_to_do),""+Constants.FUN_TO_DO,R.mipmap.ic_todo));
        funList.add(new FunctionEntity(getString(R.string.have_been_done),""+Constants.FUN_BEEN_DONE,R.mipmap.ic_havedone));

        adapter.setList( funList );
        adapter.setOnItemClickListener((adapter1, view1, position) -> {

            Bundle bundle = new Bundle();
            switch ( Integer.parseInt( adapter.getItem(position).getContentTag() ) )
            {

                case Constants.FUN_TO_DO:
                    ComFragmentActivity.startView(getActivity(),Constants.VIEW_TO_EXAMINE);
                    break;
                case Constants.FUN_BEEN_DONE:

                    startActivity( new Intent( getActivity() ,ShenPiActivity.class ));
                    break;
            }
            //ToastUtils.showShort( adapter.getItem(position).getTitle() );

        });
    }
}
